//#define __DEBUG__
// by Xeno
#define THIS_FILE "x_playerammobox.sqf"
#include "x_setup.sqf"
private ["_box","_box_array"];

__TRACE_1("_this","_this");

_box_array = [];

#ifndef __TT__
_box_array = GVAR(player_ammobox_pos);
#else
_box_array = if (GVAR(player_side) == blufor) then {GVAR(player_ammobox_pos) select 0} else {GVAR(player_ammobox_pos) select 1};
#endif

__TRACE_2("the_base_box",QGVAR(the_base_box),"_box_array");

_box = GVAR(the_base_box) createVehicleLocal (_box_array select 0);
_box setDir (_box_array select 1);
_box setPos (_box_array select 0);
player reveal _box;

// TYRGHEN
// _box addAction [(localize "STR_DOM_MISSIONSTRING_300") call FUNC(BlueText), {_this call FUNC(savelayout)}];
// _box addAction [(localize "STR_DOM_MISSIONSTRING_301") call FUNC(BlueText), {_this call FUNC(clearlayout)}];
// _box addAction [(localize "STR_DOM_MISSIONSTRING_302") call FUNC(BlueText), {_this call FUNC(getbackpack)}];
// [_box] call FUNC(weaponcargo);
[_box] call FUNC(init_boxnet);

GVAR(player_ammobox_pos) = nil;

// no other support except creating one.
// means the box is not filled after x minutes again
if (GVAR(WithAcre)) then {
	_acbpos = _box modelToWorld [5,0,0];
	_acbpos set [2,0];
	_acbox = "ACRE_RadioBox" createVehicleLocal _acbpos;
	_acbox setDir (direction _box);
	_acbox allowDamage false;
	player reveal _acbox;
};

// TYRGHEN - With the VAS there is no need to refill the box
//[_box,_box_array] execFSM "fsms\PlayerAmmobox.fsm";
